package com.ee.bruscar.configuration;

import java.util.ArrayList;
import java.util.List;

import com.ee.bruscar.configuration.hint.DataModelHint;
import com.ee.bruscar.configuration.hint.Hint;
import com.ee.bruscar.configuration.hint.ListMethodHint;
import com.ee.bruscar.configuration.hint.MemberHint;
import com.ee.bruscar.configuration.hint.MethodHint;
import com.ee.bruscar.configuration.hint.ModelHint;
import com.ee.bruscar.generator.StringUtils;

public class InterfaceConfiguration
{
	private String interfaceToHonour;
	private String stubClass;
	private String srcPath;
	
	private List<MethodHint> methodHints;
	private List<ModelHint> modelHints;

	public InterfaceConfiguration()
	{
	}
	
	public InterfaceConfiguration(String interfaceName, String outputClassName, String srcPath )
	{
		this.interfaceToHonour = interfaceName;
		this.stubClass = outputClassName;
		this.srcPath = srcPath;
	}

	public List<MethodHint> getMethodHints()
	{
		return methodHints;
	}

	public void setMethodHints(List<MethodHint> methodHints)
	{
		this.methodHints = methodHints;
	}
	
	public List<ListMethodHint> getListHints()
	{
		List<ListMethodHint> result = new ArrayList<ListMethodHint>();
		for( MethodHint hint : methodHints )
		{
			if( hint instanceof ListMethodHint )
			{
				result.add( (ListMethodHint) hint );
			}
		}
		return result;
	}
	
	public void setInterfaceToHonour(String interfaceToHonour)
	{
		this.interfaceToHonour = interfaceToHonour;
	}

	public void setStubClass(String stubClass)
	{
		this.stubClass = stubClass;
	}

	public void setSrcPath(String srcPath)
	{
		this.srcPath = srcPath;
	}

	public String getSrcPath()
	{
		return srcPath;
	}

	public String getStubClass()
	{
		return stubClass;
	}

	public String getInterfaceToHonour()
	{
		return interfaceToHonour;
	}
	
	public Class<?> getInterfaceToHonourClass()
	{
		try
		{
			return Class.forName( interfaceToHonour );
		} 
		catch (ClassNotFoundException e)
		{
			throw new RuntimeException("Can't load a class for: " + interfaceToHonour );
		}
	}
	
	public List<ModelHint> getModelHints()
	{
		return modelHints;
	}

	public void setModelHints(List<ModelHint> modelHints)
	{
		this.modelHints = modelHints;
	}

	public String getHint(String className, String setterName)
	{
		return null;
//		for( DataModelHint modelHint : dataModelHints )
//		{
//			if( modelHint.supports( className ) )
//			{
//				return modelHint.getHint( setterName );
//			}
//		}
//		return setterName;
	}
	
	public String getPackage() 
	{
		return StringUtils.getPackage( getStubClass() );
	}
	
	public String getSimpleClassName() 
	{
		return StringUtils.getSimpleClassName( getStubClass() );
	}

//	public List<Hint> getHints()
//	{
//		
////		List<Hint> hints = new ArrayList<Hint>();
////		for( DataModelHint dmHint : dataModelHints )
////		{
////			System.out.println( dmHint.getClassName() );
////			for( MemberHint memberHint : dmHint.getMemberHints() )
////			{
////				System.out.println( memberHint.getMemberName() );
////				//Hint hint = new Hint( dmHint.getClassName(), memberHint.getMemberName(), memberHint.getHint() );
////				//hints.add( hint );
////			}
////		}
////		return hints;
//	}
}
